home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 735 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.2 KB

  1. From: Rich Paul <rpaul@trcinc.com>
  2. Message-ID: <31498AE5.2CA3@trcinc.com>
  3. X-Original-Date: Fri, 15 Mar 1996 10:21:09 -0500
  4. Path: in1.uu.net!bounce-back
  5. Date: 16 Mar 96 07:38:47 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: no operator bool()?
  9. Organization: Technical Resource Connection
  10. References: <313ddfd9.16044605@sqarc.sq.com> <313E19BB.5AE2E407@cantrip.org> <31445809.5921189@news.ultranet.com>
  11. X-Mailer: Mozilla 2.0 (WinNT; I)
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMUpwEuEDnX0m9pzZAQEW7gF/R/UjJMwYU+6Q96HVT3rJxGJNPfhHRrWi
  14.     32s8j2GHawiEOqdJT5bUFwEwap5ofpGJ
  15.     =aLUA
  16.  
  17. Pablo Halpern wrote:
  18. > "Nathan Myers, http://www.cantrip.org/" <ncm@cantrip.org> wrote:
  19. > >Automatic conversions can be a problem in general, but the problems
  20. > >with automatic conversions to a numeric type are ridiculous.
  21. > >Compatibility with C has its downside.
  22. > >
  23. > >As a side note...  The problem with automatic conversions is not
  24. > >only that the conversion may be called unexpectedly; the
  25. > >possibility of the conversion affects overloading, so it may
  26. > >force you to add "unnecessary" casts to guide the compiler to
  27. > >the correct choice of function to call.
  28. > Sounds like another reason to permit the keyword "explicit" to apply to
  29. > conversion operators. I really don't see why the committee is so
  30. > resistant to this concept. I think the following would be a perfectly
  31. > satisfactory usage:
  32. >    class istream : public ...
  33. >    {
  34. >      ...
  35. >      explicit operator bool() const;
  36. >      ...
  37. >    };
  38. >    void f()
  39. >    {
  40. >      while (bool(cin))
  41. >        // do something
  42. >    }
  43. > Its clear. Its easy to remember. Its clean. Same would work for
  44. > auto_ptr<>.
  45.  
  46. I'd agree with that.  An explicit cast from a string to a <charT> * would be 
  47. nice as well ... much cleaner than c_str() and data().
  48. ---
  49. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  50. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  51. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  52. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  53. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  54.